//-----------------------------------------------------
// vector.cpp
//-----------------------------------------------------

/**
 * @file vector.cpp
 */

#include "vector.h"

#define _USE_MATH_DEFINES
#include <cmath>

namespace tools {

	float deg2rad(float deg) 
	{
		return (float) (deg * M_PI / 180);
	}

	CVector CVector::getUnitVectorFromOrientation(float orientation) 
	{
		return CVector(sin(deg2rad(orientation)), 0, -cos(deg2rad(orientation)));
	}

	float CVector::modulo() const 
	{
		return sqrt(x * x + y * y + z * z);
	}

	void CVector::normalize() 
	{
		float mod = modulo();

		if (mod != 1.0) {
			x /= mod;
			y /= mod;
			z /= mod;
		}
	}



} // namespace tools